#include <cstdio>
#include <cstring>

const    int        limitSize    = 100000 + 10;

struct        Interval
{
    int        p , r , m;
    Interval    *left , *right;
    int        tot , sum;
};

int            n , m;
int            list    [limitSize];

int            top;
Interval        ctree    [limitSize * 2];

void    init()
{
    scanf("%d" , &n);
    int i;
    for(i = 0; i < n; i ++)
        scanf("%d" , list + i);
}

void    buildTree(Interval *t)
{
    if( t->p + 1 == t->r )
    {
        t->tot = 0; t->sum = list[t->p]; return;
    }

    t->m = (t->p + t->r) / 2;
    t->left = &ctree[ ++ top ];
    t->left->p = t->p; t->left->r = t->m;
    buildTree( t->left );

    t->right = &ctree[ ++ top ];
    t->right->p = t->m; t->right->r = t->r;
    buildTree( t->right );

    t->sum = t->left->sum + t->right->sum;
    t->tot = 0;
}

void    passFlag(Interval *t)
{
    t->left->tot += t->tot; t->left->sum += (t->m - t->p) * t->tot;
    t->right->tot += t->tot; t->right->sum += (t->r - t->m) * t->tot;
    t->tot = 0;
}

void    modify(Interval *t , int p , int r , int x)
{
    if( t->p == p && t->r == r )
    {
        t->sum += (r - p) * x;
        t->tot += x;
        return;
    }

    if(t->tot) passFlag(t);
    if(r <= t->m) modify(t->left , p , r , x);
    else if(p >= t->m) modify(t->right , p , r , x);
    else
    {
        modify(t->left , p , t->m , x);
        modify(t->right , t->m , r , x);
    }

    t->sum = t->left->sum + t->right->sum;
}

int    query(Interval* t , int p , int r)
{
    if( t->p == p && t->r == r ) return t->sum;
    if( t->tot ) passFlag( t );

    if( r <= t->m ) return query(t->left , p , r);
    else if( p >= t->m ) return query(t->right , p , r);
    else return query(t->left , p , t->m) + query(t->right , t->m , r);
}

void    solve()
{
    top = 0;
    ctree[0].p = 0; ctree[0].r = n;
    buildTree( ctree );

    char        command[10];
    int        p , r , k;

    while( scanf("%s" , command) != EOF )
    {
        if ( command[0] == 'E' )
            break;
        if ( command[0] == 'A' )
        {
            scanf("%d%d%d" , &p , &k); r = p; p --;
            modify( ctree , p , r , k );
        }
        if ( command[0] == 'S' )
        {
            scanf("%d%d%d" , &p , &k); r = p; p --;
            modify( ctree , p , r , -k );
        }
        if ( command[0] == 'Q' )
        {
            scanf("%d%d" , &p , &r); p --;
            printf("%d\n" , query(ctree , p , r) );
        }
    }
}

int    main()
{
    int t, i;
    scanf("%d", &t);
    for ( i = 1; i <= t; i ++ )
    {
        printf("Case %d:\n", i);
        init();
        solve();
    }
    return 0;
}
